#include <bits/stdc++.h>
// 2025/01/23
// tag: 
// Author: Zhang Muen
using namespace std;

int soduku[9][9];
bool row[9][10], col[9][10], block[3][3][10], flag;

void dfs(int x, int y){
    if (flag)
        return;
    if (x == 9){
        flag = true;
        for (int i = 0; i < 9; i++){
            for (int j = 0; j < 9; j++)
                cout << soduku[i][j] << ' ';
            cout << endl;
        }
    }
    if (soduku[x][y]){
        if (y == 8)
            dfs(x + 1, 0);
        else
            dfs(x, y + 1);
        return;
    }
    for (int i = 1; i <= 9; i++)
        if (!row[x][i] && !col[y][i] && !block[x / 3][y / 3][i]){
            soduku[x][y] = i;
            row[x][i] = col[y][i] = block[x / 3][y / 3][i] = true;
            if (y == 8)
                dfs(x + 1, 0);
            else
                dfs(x, y + 1);
            soduku[x][y] = 0;
            row[x][i] = col[y][i] = block[x / 3][y / 3][i] = false;
        }
}

signed main()
{
    for (int i = 0; i < 9; i++)
        for (int j = 0; j < 9; j++){
            cin >> soduku[i][j];
            row[i][soduku[i][j]] = col[j][soduku[i][j]] = block[i / 3][j / 3][soduku[i][j]] = true;
        }
    dfs(0, 0);
    return 0;
}